package com.gyp.model;

import com.alibaba.fastjson.JSONObject;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class ResultUtil {

    public static void responseJson(HttpServletResponse response, Object object){
        response.setContentType("application/json;charset=UTF-8");
        response.setStatus(200);
        PrintWriter writer = null;
        try {
            writer = response.getWriter();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        writer.write(JSONObject.toJSONString(object));
        writer.flush();
        writer.close();
    }

}
